﻿namespace WMS6.Web.Administration
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class SendMessageQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlCreatedDate;
        protected DropDownList ddlIsActive;
        protected DropDownList ddlIsActiveOper;
        protected DropDownList ddlIsRead;
        protected DropDownList ddlIsReadOper;
        protected DropDownList ddlMessageTitle;
        protected DropDownList ddlToUserID;
        protected HtmlForm F1226;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlHead Head1;
        protected HtmlImage img2;
        protected Label lblCreatedDate;
        protected Label lblIsActive;
        protected Label lblIsRead;
        protected Label lblMessageTitle;
        protected Label lblToUserID;
        protected Label lblUserSendMessage;
        protected HtmlLink mycss;
        protected TextBox txtCreatedDate;
        protected TextBox txtCreatedDate2;
        protected TextBox txtMessageTitle;
        protected TextBox txtToUserID;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("SendMessageList.aspx?action={0}&from='list'", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("SendMessageList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnExport.Visible = false;
                this.hdnActionID.Value = base.Request.QueryString["action"];
            }
        }

        private void LoadDLL()
        {
            base.InitQueryDDL(this.ddlMessageTitle, 0);
            base.InitQueryDDL(this.ddlCreatedDate, 1);
            base.InitQueryDDL(this.ddlToUserID, 0);
            base.InitQueryDDL(this.ddlIsReadOper, 0);
            base.InitQueryDDL(this.ddlIsActiveOper, 0);
            base.InitIsActiveDDL(this.ddlIsRead, 0);
            base.InitIsActiveDDL(this.ddlIsActive, 1);
            this.ddlIsActive.SelectedValue = "N";
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadDLL();
                this.LoadData();
            }
        }

        public string CreatedDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCreatedDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCreatedDate.Text.Trim(), this.ddlCreatedDate.SelectedValue, this.txtCreatedDate2.Text.Trim(), "CreatedDate");
                }
                return "";
            }
        }

        public string IsActive
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsActive.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsActive.SelectedValue, this.ddlIsActiveOper.SelectedValue);
                }
                return "";
            }
        }

        public string IsRead
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsRead.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsRead.SelectedValue, this.ddlIsReadOper.SelectedValue);
                }
                return "";
            }
        }

        public string MessageTitle
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtMessageTitle.Text.Trim()))
                {
                    return base.GetParamsString(this.txtMessageTitle.Text.Trim(), this.ddlMessageTitle.SelectedValue);
                }
                return "";
            }
        }

        public string ToUserID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtToUserID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtToUserID.Text.Trim(), this.ddlToUserID.SelectedValue);
                }
                return "";
            }
        }
    }
}

